
import ctrlr.ChatCtrlr;
import gui.ChatGUI;
import java.io.IOException;
import java.net.SocketException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import model.ChatModel;
import model.ChatModelCtrlr;
import model.ChatMsgs;
import ni.ChatNI;

/**
 *
 * @author gb
 */
public class ChatSystem {

    /**
     * Starts the ChatSystem
     *
     * @param args unused params
     */
    public static void main(String[] args) {
        //Creating controller
        ChatCtrlr ctrl = new ChatCtrlr();

        //Creating model => create userlist and chat that are shared with the GUI
        DefaultListModel userlist = new DefaultListModel();
        ChatMsgs chat = new ChatMsgs();
        ChatModel model = new ChatModel(userlist, chat);

        //Creating the model ctrlr that is the only one to really have access to the model
        ChatModelCtrlr modelCtrlr = new ChatModelCtrlr();
        modelCtrlr.setModel(model);

        //Creating the gui
        ChatGUI gui = null;
        try {
            gui = new ChatGUI(ctrl, modelCtrlr, userlist, chat);
        } catch (IOException ex) {
            Logger.getLogger(ChatSystem.class.getName()).log(Level.SEVERE, null, ex);
        }

        //Creating the ni
        ChatNI chatni = new ChatNI(ctrl, modelCtrlr);

        //Setting the links inside the controller
        ctrl.setGui(gui);
        ctrl.setNi(chatni);

    }
}
